import request from '@/utils/request'
// 定义类型
type Common<T> = {
  code: string
  data: T
  mesg: string
  time: string
}
// 菜单列表的数据
export type MenuItem = {
  createdBy: string
  createdTime: string
  description: string
  href: string
  icon: string
  id: number
  level: number
  name: string
  operatorId: number | null
  orderNum: number
  parentId: number
  shown: boolean
  updatedBy: string
  updatedTime: string
}

// 获取所有菜单项,Common<MenuItem[],表明接口请求返回的数据类型是,取出data.data[]
/*
    data{
        code:string
        data:{
            MenuItem[]
        }
        mesg:string
        time:string
    }
 */
export const getAll = () => {
  return request<Common<MenuItem[]>>({
    method: 'GET',
    url: '/boss/menu/getAll'
  })
}
